const express = require('express');
const xm = require('../database/models/xm');
const router = express.Router();
router.get('/hq', async(req, res) => {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); 
    const reqBody = req.body;
    // const model = await xm.findOne({ where: { username } })
    // if (model)
    //     return res.send({ msg: '用户名已经存在' });
    // const user = await User.create({ username, password: bcrypt.hashSync(password, 5) })
    // res.send({ msg: "注册成功" })
    // let addsql = 'INSERT INTO xm(Id,zt,bjdj,bjsj,jcsj,dd,sb,jkx,sj,bifz,bjz) VALUES(0,?,?,?,?,?,?,?,?,?,?)'
    xm.findAll().then(bjdj => {
        // console.log("All users:", JSON.stringify(users, null, 4));
        res.send(bjdj);
      });   
    // addsqlvalus[0] = reqBody.zt;
    // addsqlvalus[1] = reqBody.bjdj.toString();
    // addsqlvalus[2] = reqBody.bjsj.toString();
    // addsqlvalus[3] = reqBody.jcsj.toString();
    // addsqlvalus[4] = reqBody.dd.toString();
    // addsqlvalus[5] = reqBody.sb.toString();
    // addsqlvalus[6] = reqBody.jkx.toString();
    // addsqlvalus[7] = reqBody.sj.toString();
    // addsqlvalus[8] = reqBody.bifz.toString();
    // addsqlvalus[9] = reqBody.bjz.toString();
    
})
// router.post('/login', async(req, res) => {
//     // console.log(2)
//     // const { username, password } = req.body;
//     // const model = await User.findOne({ where: { username } })
//     // if (!model)
//     //     return res.send({ msg: '用户不存在，请注册' })
// })
router.get('/wzc', async(req, res) => {
    // const model = await xm.findAll();
    // console.log(model);
    res.send({msg:'test'})
})
module.exports = router;